<!DOCTYPE html>
<html lang="en">
<head>
    <title>交警处罚决定书单据</title>
    <#include "../inc/header.ftl"/>
</head>

<body class="no-skin">

<div class="main-container ace-save-state" id="main-container">

    <div class="main-content">
        <div class="main-content-inner">

            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <table id="MainGrid"></table>
                        <div id="toolbar">
                            <div style="padding:8px">
                                处罚决定书：<input id="billnumfind" class="easyui-textbox"
                                             style="width:140px">&emsp;
                                账户：<input id="accountcode" name="accountcode">&emsp;
                                收款时间：<input id="paybankdtfind" class="easyui-datebox" style="width:140px">&emsp;

                                传输状态：<select id="billstate" class="easyui-combobox" style="width:100px;">
                                    <option value="">全部</option>
                                    <option value="0">未发送</option>
                                    <option value="1">已发送</option>
                                </select>
                                <a href="#" onclick="javascript:searchInfo()" class="easyui-linkbutton"
                                   iconCls="icon-search">查 询</a>
                            </div>
                            <div style="padding:8px 8px 4px">
                                <a href="#" class="easyui-linkbutton" iconCls="icon-edit"
                                   onclick="javascript:editInfo()">修改</a>
                                <a href="#" class="easyui-linkbutton" iconCls="icon-redo"
                                   onclick="javascript:sendInfo(1)">发送</a>
                                <a href="#" class="easyui-linkbutton" iconCls="icon-back"
                                   onclick="javascript:sendInfo(2)">更新</a>
                                <a href="#" class="easyui-linkbutton" iconCls="icon-print"
                                   onclick="javascript:exportInfo()">导出</a>
                            </div>
                        </div>
                    </div>
                </div><!-- /.row -->
            </div><!-- /.page-content -->
            <#--修改弹框-->
            <div id="box-update" class="ui-dialog-content hide" data-options="minimizable:true,maximizable:true">
                <form class="form-horizontal" id="form-update" method="post" file="true">
                    <div class="form-group">交警处罚决定书信息详情</div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">处罚决定书</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="billnum" id="billnum" class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">当事人</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="occurname" id="occurname" class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">驾驶证号</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="certificatenum" id="certificatenum"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">处罚地大队代码</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="trafficunitnum" id="trafficunitnum"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">金额</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="funds" id="funds" class="col-xs-12 easyui-numberbox"
                                       data-options="readonly:true" style="width: 100%;"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">滞纳金</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="latefee" id="latefee" class="col-xs-12 easyui-numberbox"
                                       data-options="readonly:true" style="width: 100%;"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">收款户名</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="payeeaccountname" id="payeeaccountname"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">收款银行账号</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="payeeaccountcode" id="payeeaccountcode"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">收款银行开户行</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="payeebankname" id="payeebankname"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">处罚地自留金额</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="remainfunds" id="remainfunds"
                                       class="col-xs-12 easyui-numberbox"
                                       data-options="readonly:true" style="width: 100%;"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">采集地大队编码</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="collectunitnum" id="collectunitnum"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">采集地行政区划</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="collectcantonname" id="collectcantonname"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">采集地分成金额</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="collectfunds" id="collectfunds"
                                       class="col-xs-12 easyui-numberbox"
                                       data-options="readonly:true" style="width: 100%;"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">收款时间</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="paybankdt" id="paybankdt"
                                       class="col-xs-12 easyui-tatebox"
                                       data-options="required:true,editable:false"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">收款网点&nbsp;</label>
                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="bankstation" id="bankstationname"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="required:true,limitToList:true , missingMessage :'请选择' " style="width: 100%;"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">交易流水号&nbsp;</label>
                        <div class="col-xs-12 col-sm-3">
                                    <span class="block input-icon input-icon-right">
                                      <input type="text" name="bankaffirm" id="bankaffirm" class="col-xs-12 easyui-validatebox"  data-options="required:true" />
                                     </span>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">核心交易流水号&nbsp;</label>
                        <div class="col-xs-12 col-sm-3">
                                  <span class="block input-icon input-icon-right">
                                      <input type="text" name="hxbankaffirm" id="hxbankaffirm" class="col-xs-12 easyui-validatebox"  data-options="required:true" />
                                  </span>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">缴款方式</label>
                        <#--有一个下拉-->
                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="payway" id="payway" class="col-xs-12 easyui-validatebox"
                                       data-options="required:true" style="width: 100%;"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">专用票据号码</label>
                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="specialbillnum" id="specialbillnum"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">是否收款</label>
                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="isbankaffirm" id="isbankaffirm"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="required:true"/>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <#--修改-->
            <div id="SendBox-add" class="ui-dialog-content hide">
                <div style="padding:8px">
                    复核用户编码：<input id="usercode" class="easyui-textbox" style="width:140px" data-options="required:true">&emsp;
                    复核用户密码：<input id="userpwd" class="easyui-textbox" style="width:140px" data-options="required:true">&emsp;
                    <input id="biaoshi" hidden>&emsp;
                    <a href="#" class="easyui-linkbutton" iconCls="icon-redo" onclick="javascript:pageSendInfo()"><span
                                id="sendClean"></span></a>
                    <a href="#" class="easyui-linkbutton" iconCls="icon-back" onclick="javascript:cancelInfo()"><span
                                id="sendCleanCan"></span></a>
                </div>
                <table id="SendMainGrid"></table>
            </div>
        </div>
    </div><!-- /.main-content -->
</div><!-- /.main-container -->

<!-- basic scripts -->
<#include "../inc/basicjs.ftl"/>

<!-- inline scripts related to this page -->
<script type="text/javascript">

    jQuery(function ($) {
        listPage();
    });

    function searchInfo() {
        listPage(prefix + '/bill/illage/listIllage', 1)
    }

    function listPage(url,mark) {
        if(mark==1){
            var billnum = $('#billnumfind').val();
            var accountcode = $('#accountcode').val();
            var paybankdt = $('#paybankdtfind').val();
            var bankaffirm = $('#bankaffirmfind').val();
                // if(accountcode==null||accountcode==''){
                //     $.messager.alert('提示', '请选择账户', 'info');
                //     return;
                // }
        }

        $('#MainGrid').datagrid({
            //title:'交管二八列表',
            url: url,
            pagination: true,
            fitColumns: false,
            striped: true,
            singleSelect: false,
            loadMsg: "正在努力加载数据，请稍后...",
            idField: 'billnum',
            queryParams: {billnum: billnum, accountcode:accountcode, paybankdt: paybankdt},
            columns: [[
                {field: 'ck', checkbox: true},
                {title: '处罚决定书号', field: 'billnum', width: 100},
                {title: '当事人', field: 'occurname', width: 110},
                {title: '驾驶证号', field: 'certificatenum', width: 110},
                {title: '处罚地大队代码', field: 'trafficunitnum', width: 110},
                {title: '金额', field: 'funds', width: 100},
                {title: '滞纳金', field: 'latefee', width: 100},
                {title: '收款银行开户行', field: 'payeebankname', width: 110},
                {title: '收款户名', field: 'payeeaccountname', width: 100},
                {title: '收款银行账号', field: 'payeeaccountcode', width: 100},
                {title: '处罚地自留金额', field: 'remainfunds', width: 100},
                {title: '采集地大队编码', field: 'collectunitnum', width: 100},
                {title: '采集地行政区划', field: 'collectcantonname', width: 100},
                {title: '采集地分成金额', field: 'collectfunds', width: 100},
                {title: '收款时间', field: 'paybankdt', width: 100},
                {title: '收款网点', field: 'bankstation', width: 100},
                {title: '交易流水号', field: 'bankaffirm', width: 100},
                {title: '核心交易流水号', field: 'hxbankaffirm', width: 100},
                {
                    title: '缴款方式', field: 'payway', width: 100, formatter: function (value) {
                        if (value == 1) return '现金'
                        if (value == 2) return '支票';
                        if (value == 3) return '转账';
                        if (value == 4) return '其他';
                    }
                },
                {title: '专用票据号码', field: 'specialbillnum', width: 100},
                {
                    title: '是否收款', field: 'isbankaffirm', width: 100, formatter: function (value) {
                        if (value == 1) {
                            return '已收款';
                        } else {
                            return "未收款";
                        }
                    }
                },
                {title: '付款网点', field: 'bankstation', width: 100,},
                {title: '交易流水号', field: 'bankaffirm', width: 100},
                {title: '核心交易流水号', field: 'hxbankaffirm', width: 100}

            ]],
            toolbar: '#toolbar'
        });
        $(window).resize(function () {
            $('#MainGrid').datagrid('resize');
        });
    }

    function showForm() {
        $("#box-update").removeClass('hide').dialog({
            title: '&nbsp;修改',
            iconCls: 'icon-save',
            width: 800,
            height: 500,
            modal: true,
            buttons: [{
                text: '保存',
                iconCls: 'icon-ok',
                width: 80,
                plain: false,
                handler: function () {
                    $('#form-update').form({
                        url: prefix + '/bill/illage/saveIllage',
                        onSubmit: function () {
                            var isValid = $(this).form('validate');
                            if (isValid > 0) {
                                $.messager.progress({
                                    title: '提示',
                                    msg: '数据处理中，请稍候……',
                                    text: ''
                                });
                            }
                            return isValid;
                        },
                        success: function (data) {
                            $.messager.progress('close');
                            var data = eval('(' + data + ')');
                            if (data.success) {
                                billstate: $('#billstate').val();
                                searchInfo();
                                $('#box-update').dialog('close');
                            }
                            $.messager.alert('提示', data.msg, 'info');

                        }
                    });
                    $('#form-update').submit();
                }
            }, {
                text: '取消',
                iconCls: 'icon-cancel',
                width: 80,
                plain: false,
                handler: function () {
                    $('#box-update').dialog('close')
                }
            }]
        });
    }
    $('#MainGrid').datagrid({
        onDblClickCell: function(index){
            $("#MainGrid").datagrid("selectRow",index);
            editInfo();
        }
    });
    function editInfo() {
        var rows = $('#MainGrid').datagrid('getSelections');
        if (rows.length == 0) {
            $.messager.alert('提示', '请选择要编辑的数据', 'info');
            return;
        }
        if (rows.length>1) {
            $.messager.alert('提示', '修改操作不能多选', 'info');
            return;
        }
        $('#form-update').form('load',rows[0]);
        showForm();

    }

    //收款网点下拉框
    $('#bankstationname').combobox({
        url: prefix + '/base/basedata/findBankStation',
        valueField: 'bankstationname',
        textField: 'bankstationname'
    });
    //缴款方式下拉
    $('#payway').combobox({
        url: prefix + '/base/basedata/findPayWay',
        valueField: 'paywayid',
        textField: 'paywayname',
        panelHeight:'auto',
        onLoadSuccess:function(){
            var data = $('#payway').combobox('getData');//获取所有下拉框数据
            if (data.length > 0) {
                //如果有数据的话默认选中第一条数据
                $('#payway').combobox('select',data[0].paywayid);
            }
        }
    })

    //-------发送页面弹窗
    function sendInfo(opt) {
        $('#biaoshi').val(opt);
        var tit = (opt == 1) ? '发送' : '更新';
        if (opt == 1) {
            $('#sendClean').text('确认发送');
            $('#sendCleanCan').text('取消发送');
        } else {
            $('#sendClean').text('确认更新');
            $('#sendCleanCan').text('取消更新');
        }
        var row = $('#MainGrid').datagrid('getSelections');
        if (row.length == 0) {
            $.messager.alert('提示', '请选择数据', 'info');
            return;
        }
        console.log(row);
        $("#SendBox-add").removeClass('hide').dialog({
            title: '&nbsp;' + tit,
            iconCls: 'icon-add',
            width: 600,
            height: 500,
            modal: true,
            buttons: [{
                text: '取消',
                iconCls: 'icon-cancel',
                width: 80,
                plain: false,
                handler: function () {
                    $('#SendBox-add').dialog('close')
                }
            }]
        });


        var list = [];
        $.each(row, function (index, value) {
            list.push(value.billid)
        });
        // 右侧表格
        $('#SendMainGrid').datagrid({
            data: row,
            fitColumns: false,
            striped: false,
            singleSelect: false,
            modal: false,
            loadMsg: "正在加载数据，请稍后...",
            columns: [[
                {title: '流水号', field: 'iaiid', width: 100},
                {title: '处罚决定书号', field: 'billnum', width: 100},
                {title: '当事人', field: 'occurname', width: 110},
                {title: '驾驶证号', field: 'certificatenum', width: 110},
                {title: '处罚地大队代码', field: 'trafficunitnum', width: 110},
                {title: '金额', field: 'funds', width: 100},
                {title: '滞纳金', field: 'latefee', width: 100},
                {title: '代理银行id', field: 'bankid', width: 100},
                {title: '银行名称', field: 'payeebankname', width: 110},
                {title: '庄户名称', field: 'payeeaccountname', width: 100},
                {title: '账户', field: 'payeeaccountcode', width: 100},
                {title: '是否分成', field: 'isscale', width: 100},
                {title: '处罚地自留金额', field: 'remainfunds', width: 100},
                {title: '采集地大队编码', field: 'collectunitnum', width: 100},
                {title: '采集地行政区划', field: 'collectcantonid', width: 100},
                {title: '采集地行政区划', field: 'collectcantoncode', width: 100},
                {title: '采集地行政区划', field: 'collectcantonname', width: 100},
                {title: '采集地分成金额', field: 'collectfunds', width: 100},
                {title: '银行收款时间', field: 'paybankdt', width: 100},
                {title: '收款网点', field: 'bankstation', width: 100},
                {title: '银行交易流水号', field: 'banksaffirm', width: 100},
                {
                    title: '缴款方式', field: 'payway', width: 100, formatter: function (value) {
                        if (value == 1) return '现金'
                        if (value == 2) return '支票';
                        if (value == 3) return '转账';
                        if (value == 4) return '其他';
                    }
                },

                {title: '信息状态', field: '', width: 100},
                {title: '专用票据编码', field: 'specialbillnum', width: 100},
                {title: '发送时间', field: 'sendtime', width: 100},


                {
                    title: '是否异地', field: 'insohere', width: 100, formatter: function (value) {
                        if (value == 1) {
                            return "是";
                        } else {
                            return '否';
                        }
                    }
                },
                {
                    title: '是否开票', field: 'isspecialbill', width: 100, formatter: function (value) {
                        if (value == 1) {
                            return '是';
                        } else {
                            return "否";
                        }
                    }
                },
                {
                    title: '状态', field: 'billstate', width: 100, formatter: function (value) {

                        if (value == 3) {
                            return '已缴费';
                        } else {
                            return '未交费';
                        }
                    }
                },

                {title: '核心交易流水号', field: 'hxbankaffirm', width: 100},
                {
                    title: '发送状态', field: 'issend', width: 100, formatter: function (value) {
                        if (value == 1) {
                            return '是';
                        } else {
                            return '否';
                        }
                    }
                }
            ]],
        });
    }

    //  ----------------确认发送
    function pageSendInfo() {
        var usercode = $('#usercode').val();
        var userpwd = $('#userpwd').val();
        if (usercode == null || usercode == '') {
            $.messager.alert('提示', '请输入用户编码', 'info');
            return;
        }
        if (userpwd == null || userpwd == '') {
            $.messager.alert('提示', '请输入用户密码', 'info');
            return;
        }
        var row = $('#SendMainGrid').datagrid('getData');
        var list = [];
        $.each(row.rows, function (index, value) {
            list.push(value.iaiid)
        });

        var opt = $('#biaoshi').val();
        console.log(opt);
        var url = (opt == 1) ? '/bill/illage/sendIllage' : '/bill/illage/updateIllage';
        var billids = [];
        $.ajax({
            url: prefix + url,
            type: 'POST',
            data: {
                usercode: usercode,
                userpwd: userpwd,
                billids: list.toString()
            },
            dataType: 'json',
            success: function (data) {
                $.messager.alert('提示', data.msg, 'info');
            }
        });
    }

    function exportInfo() {
        var row = $('#MainGrid').datagrid('getSelections');
        var billids = [];
        $.each(row, function (index, value) {
            billids.push(value.iaiid)
        });
        var accountcode = $('#accountcode').val();
        if (accountcode == null || accountcode == '') {
            $.messager.alert('提示', '请选择账户', 'info');
            return;
        }
        console.log(billids);
        if (row == '' || row.length < 1) {
            $.messager.alert('提示', '请选择要导出的数据', 'info');
            return;
        }
        var downurl = prefix + '/bill/illage/illageExport?1=1';

        billids == "" ? downurl = downurl : downurl = downurl + "&billids=" + billids;
        window.location.href = downurl;
    }


    function cancelInfo() {
        $('#SendBox-add').dialog('close')
    }
    $('#accountcode').combogrid({
        panelWidth:550,
        idField:'accountcode',
        textField:'accountcode',
        url:prefix+'/base/basedata/findBank',
        columns:[[
            {field: 'ck', checkbox: true},
            {field:'cantonname',title:'区划',width:80},
            {field:'accountcode',title:'账号',width:160},
            {field:'bankname',title:'开户行名称',width:260}
        ]]
    });

</script>
</body>
</html>
